
* Figure 1 

clear all	
cd "${data}"	
use "data1.dta", clear 


mixed c.IMD3007_ c.daysafter##c.IMD5012_ || country_: || election_: || respondent: IMD5012_ 
margins, dydx(IMD5012_) at(daysafter=(0(30)300)) post

 marginsplot, ///
    ytitle("AME of a one-unit change in party position", size(3)) ///
    recastci(rarea) ciopt(color(gs12%50)) level(95) ///
    recast(line) plot1opts(color(gs12%50) lpattern(shortdash)) ///
    title("") ///
    addplot(hist daysafter, percent color(gs12%50) yaxis(2) ///
        ytitle("percent", size(3) axis(2)) ///
        yscale(range(0(5)25) axis(2) alt)) ///
    legend(off) ///
    xscale(range(0(30)300)) ///
    xlabel(0(30)300, grid glpattern(solid) glcolor(gs14) glwidth(vthin)) ///
    ylabel(, grid glpattern(solid) glcolor(gs14) glwidth(vthin)) ///
    plotr(lp(solid) lcolor(black)) ///
    xtitle("days since election", size(3))

graph save "${figures}/figure1.gph", replace
graph export "${figures}/figure1.png", replace 

 
 
 